package com.jemframework.domain.propertyconverter;

import java.util.Date;

public class DatePropertyConverter {

  public Object getAsObject(String string) {

    if (string == null || string.trim().length() == 0) {
      return null;
    }

    long theTime = Long.valueOf(string);
    Date theDate = new Date(theTime);
    return theDate;
  }

  public String getAsString(Object property) {

    if (property == null) {
      return "";
    }

    Date theProperty = (Date) property;
    return Long.toString(theProperty.getTime());
  }
}
